package com.jz.netthings.application.providerCreate.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jz.netthings.application.providerCreate.bean.ProviderZw;
import com.jz.netthings.application.providerCreate.mapper.mysql.ProviderZwMapper;
import com.jz.netthings.application.providerCreate.service.ProviderZwService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jz.netthings.application.providerCreate.bean.ProviderZw;
import com.jz.netthings.bean.system.JyCode;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.system.mapper.mysql.JyCodeMapper;
import com.jz.netthings.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-03-05
 */
@Service
public class ProviderZwServiceImpl extends ServiceImpl<ProviderZwMapper, ProviderZw> implements ProviderZwService {
     @Autowired
    JyCodeMapper  jyCodeMapper;
    @Override
    public List<ProviderZw> selectByProviderNo(String id) throws AdscmSystemException {
        Wrapper<ProviderZw> providerZwEntityWrapper=new EntityWrapper<>();
        providerZwEntityWrapper.eq("providerNo",Long.valueOf(id));
        List<ProviderZw> providerZws = super.selectList(providerZwEntityWrapper);
        for (ProviderZw providerZw : providerZws) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(providerZw.getCode(),null)){
                JyCode  jyCode=new JyCode();
                jyCode.setType(5);
                jyCode.setCode(providerZw.getCode());
                 jyCode = jyCodeMapper.selectOne(jyCode);
                providerZw.setCodeName(jyCode.getName());
            }
        }
        return providerZws;
    }
}
